//
//  EvaluateCell.m
//  MM
//
//  Created by 郑渊文 on 6/1/15.
//  Copyright (c) 2015 王晨辉. All rights reserved.
//

#import "EvaluateCell.h"
#import "EvaluateCellFrame.h"
#import "EvaluateModel.h"
#import "ComponentsFactory.h"
#import "CommonMacro.h"
#import "StarView.h"

@interface EvaluateCell()
{
    UILabel *evaluateContent; //评价内容
    UILabel *evaluateUser;     //用户名字
    UILabel *evaluateTime;    //评论时间
    StarView *evaluateStar;   //评分
     UIImageView *myUserImg;   //头像

    
}
@end

@implementation EvaluateCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self initConfig];
//        self.backgroundColor = [UIColor redColor];
    }
    return self;
}


-(void)initConfig
{
    //评价内容
    evaluateContent = [[UILabel alloc] init];
    evaluateContent.font = [UIFont systemFontOfSize:16.0f];
    evaluateContent.numberOfLines = 0;
    [evaluateContent setTextColor:[ComponentsFactory createColorByHex:@"#1b1a1a"]];
    [self.contentView addSubview:evaluateContent];
    
    //用户帐号
    evaluateUser = [[UILabel alloc] init];
    [evaluateUser setFont:[UIFont systemFontOfSize:14]];
    [evaluateUser setTextColor:[ComponentsFactory createColorByHex:@"#b8b8b8"]];
    [self.contentView addSubview:evaluateUser];
    
    //评论时间
    evaluateTime = [[UILabel alloc] init];
    [evaluateTime setFont:[UIFont systemFontOfSize:14]];
    [evaluateTime setTextColor:[ComponentsFactory createColorByHex:@"#b8b8b8"]];
    [self.contentView addSubview:evaluateTime];
    
    //评价等级
    evaluateStar = [[StarView alloc] initWithFrame:CGRectMake(220, 45, 80, 20)];
    evaluateStar.userInteractionEnabled = NO;
    [self.contentView addSubview:evaluateStar];
    
   
}


//-(void)initConfig
//{
//    //评价内容
//    _evaluateContent = [[UILabel alloc] initWithFrame:CGRectMake(20, 50,SCREEN_WIDTH-40,150)];
//    _evaluateContent.font = [UIFont systemFontOfSize:16.0f];
//    _evaluateContent.numberOfLines = 0;
//    _evaluateContent.textColor = [UIColor blackColor];
////    [_evaluateContent setTextColor:[ComponentsFactory createColorByHex:@"#1b1a1a"]];
//    [self addSubview:_evaluateContent];
//    
//    //用户帐号
//    _evaluateUser = [[UILabel alloc] initWithFrame:CGRectMake(70, 10, 80, 50)];
//    [_evaluateUser setFont:[UIFont systemFontOfSize:14]];
//    _evaluateUser.textColor = [UIColor blackColor];
////    [_evaluateUser setTextColor:[ComponentsFactory createColorByHex:@"#b8b8b8"]];
//    [self addSubview:_evaluateUser];
//    
//    //评论时间
//    _evaluateTime = [[UILabel alloc] initWithFrame:CGRectMake(120, 10, 120, 50)];
//    [_evaluateTime setFont:[UIFont systemFontOfSize:14]];
//    [_evaluateTime setTextColor:[ComponentsFactory createColorByHex:@"#b8b8b8"]];
//    [self addSubview:_evaluateTime];
//    
//    //评价等级
//    _evaluateStar = [[StarView alloc] initWithFrame:CGRectMake(230,25, 40, 15)];
//    _evaluateStar.userInteractionEnabled = NO;
////    [_evaluateStar initWithFrame:CGRectMake(220,10, 50, 20) score:_score];
//    [self addSubview:_evaluateStar];
//    
////    //回复内容
////    replyContent = [[UITextView alloc] init];
////    //replyContent.numberOfLines = 0;
////    replyContent.font = [UIFont systemFontOfSize:15];
////    replyContent.scrollEnabled = NO;
////    [replyContent setTextColor:[ComponentsFactory createColorByHex:@"#414141"]];
////    replyContent.backgroundColor = [ComponentsFactory createColorByHex:@"#fff4de"];
////    [self.contentView addSubview:replyContent];
////    
////    //回复人
////    replyName = [[UILabel alloc] init];
////    replyName.textAlignment = NSTextAlignmentRight;
////    replyName.font = [UIFont systemFontOfSize:12];
////    [replyName setTextColor:[ComponentsFactory createColorByHex:@"#b8b8b8"]];
////    replyName.backgroundColor = [UIColor clearColor];
////    [self.contentView addSubview:replyName];
//}

//- (void)setFrame:(CGRect)frame
//{
//    frame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height - 2);
//    [super setFrame:frame];
//}
//
- (void)setMyEvaluateCellFrame:(EvaluateCellFrame *)myEvaluateCellFrame
{
    _myEvaluateCellFrame = myEvaluateCellFrame;
    
    evaluateContent.frame = _myEvaluateCellFrame.evaluateContentFrame;
    evaluateContent.text = _myEvaluateCellFrame.evaluateModel.evaluateContent;
    
    evaluateUser.frame = _myEvaluateCellFrame.evaluateUserFrame;
    evaluateUser.text = _myEvaluateCellFrame.evaluateModel.evaluateUser;
    
    evaluateTime.frame = _myEvaluateCellFrame.evalateTimeFrame;
    evaluateTime.text = _myEvaluateCellFrame.evaluateModel.evalateTime;
    
    evaluateStar.frame = _myEvaluateCellFrame.evaluatesStarFrame;
    evaluateStar.currScore = [_myEvaluateCellFrame.evaluateModel.evaluatesStar intValue];
    
    myUserImg.frame = _myEvaluateCellFrame.evalateUserImgFrame;
    myUserImg.image = _myEvaluateCellFrame.evaluateModel.UserImg;
    
}

@end
